import {deleteAction, getAction, postAction, downFile, getFileAccessHttpUrl} from '@/api/request'

export const application12 = {

    data() {
        // 重复银行卡账号验证
        const ssca0011AgainCheck = async (rule, value, callback) => {
            if (!this.formValidate.ssca0011_again) {
                return callback(new Error('请再次输入银行卡账号！'));
            }
            else if (this.formValidate.ssca0011 != this.formValidate.ssca0011_again) {
                return callback(new Error('两次输入银行卡账号不一致！'));
            } else {
                callback()
            }
        };
        return {
            url: {
                tab12Infor: "/api/ac/subsistence/ss12001ChangeService/createTab12Infor",
                tab12Submit: "/api/ac/subsistence/ss12001ChangeService/updateTab12Submit",
                getMemberList: "/api/ac/subsistence/ss12001ChangeService/getMemberList"
            },
            memberList: [],
            Loading: false,
            familyInfo: {},
            submitDisabled: true,
            disabled: true,
            information: "",
            memberInformation: "",
            ruleValidate: {
                ssca0044: [
                    {required: true, message: '家庭月基础收入金额不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0045: [
                    {required: true, message: '家庭月赡抚养费金额不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0046: [
                    {required: true, message: '家庭月财产收入金额不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0047: [
                    {required: true, message: '家庭月基础支出金额不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0049: [
                    {required: true, message: '家庭月总收入金额不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0051: [
                    {required: true, message: '家庭人口数不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0042: [
                    {required: true, message: '保障标准不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0052: [
                    {required: true, message: '保障人口数不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0025: [
                    {required: true, message: '分类救助上浮总金额不能为空！', trigger: 'blur', type: "number"}
                ],
                ssca0004: [
                    {required: true, message: '差额保障金额不能为空！', trigger: 'blur', type: "number"}
                ],
                ssca0026: [
                    {required: true, message: '总保障金额不能为空！', trigger: 'blur', type: "number"}
                ],
                ssca0065: [
                    {required: true, message: '高龄补贴总金额不能为空！', trigger: 'blur', type: "number"}
                ],
                ssca0013: [
                    {required: true, message: '请选择致贫原因！', trigger: 'change'}
                ],
                ssca0009: [
                    {required: true, message: '请前往【低保救助业务办理】【银行帐户信息维护】补全信息！', trigger: 'change'}
                ],
                ssca0082: [
                    {required: true, message: '请前往【低保救助业务办理】【银行帐户信息维护】补全信息！', trigger: 'change'}
                ],
                ssca0010: [
                    {required: true, message: '请前往【低保救助业务办理】【银行帐户信息维护】补全信息！', trigger: 'blur'}
                ],
                ssca0083: [
                    {required: true, message: '请前往【低保救助业务办理】【银行帐户信息维护】补全信息！', trigger: 'blur'}
                ],
                ssca0011: [
                    {required: true, message: '请前往【低保救助业务办理】【银行帐户信息维护】补全信息！', trigger: 'blur'}
                ],
                ssca0011_again: [
                    {required: true, message: '请再次输入银行卡账号！', validator: ssca0011AgainCheck, trigger: 'blur'}
                ],
                ssca0033: [
                    {required: true, message: '变更时间不能为空！', trigger: 'change', pattern: /.+/}
                ],
                ssca0037: [
                    {required: true, message: '停保申请时间不能为空！', trigger: 'change', pattern: /.+/}
                ],
                ssca0059: [
                    {required: true, message: '迁移时间不能为空！', trigger: 'change', pattern: /.+/}
                ],
                ssca0089: [
                    {required: true, message: '请选择是否入户调查、民主评议、审批公示！', trigger: 'change'}
                ],
                ssca0090: [
                    {required: true, message: '请选择是否进行经济核查！', trigger: 'blur'}
                ],
                ssca0030: [
                    {required: true, message: '请选择停保原因！', trigger: 'change'}
                ],
                ssca0092: [
                    {required: true, message: '请选择停保类型！', trigger: 'change'}
                ],
                ssca0034: [
                    {required: true, message: '变更原因说明不能为空！', trigger: 'blur'}
                ],
                ssca0035: [
                    {required: true, message: '停保原因说明不能为空！', trigger: 'blur'}
                ],
                ssca0060: [
                    {required: true, message: '迁移原因说明不能为空！', trigger: 'blur'}
                ],
                ssca0094: [
                    {required: true, message: '请选择完整区划！', trigger: 'change', pattern: /^((?!000$).)*$/}
                ]
            },

        }
    },
    methods: {
        //提交申请
        prevStep() {
            this.$emit('prevStep')
        },
        nextStep() {
            console.log(this.formValidate)
            this.formValidate.oldBpmStatus = this.bpmStatus;
            this.formValidate.oldSs12001Id = this.$parent.familyInfo.oldSs12001Id;
            if (this.formValidate.ssca0090 == '0' && this.isValidate) {
                //如果选【否】，需要进行确认操作，确认信息提示本次变更家庭成员结构发生了哪些变化
                this.$Modal.confirm({
                    title: this.validateMessage,
                    onOk: () => {
                        this.tab12Submit();
                    }
                })
            } else {
                this.tab12Submit();
            }

        },
        printSs00011() {
            this.$refs.printModal.edit(this.$parent.familyInfo.ss12001Id);
        },
        changeSubmit() {
            this.submitDisabled = false
        },
        changeSsca0082() {
            this.formValidate.ssca0083 = "";
            this.formValidate.ssca0010 = "";
        },
        changeSsca0010(obj) {
            this.$set(this.formValidate, "ssca0083", obj);
        },
        tab12Submit() {
            this.Loading = true;
            var that = this;
            this.$refs['formValidate'].validate((valid) => {
                if (valid) {
                    postAction(that.url.tab12Submit, this.formValidate).then((res) => {
                        if (res.data.errcode == 0) {
                            that.$Message.success("提交申请成功！");
                            that.$emit('finish');
                        } else {
                            that.$Message.error(res.data.errmsg);
                        }
                    }).finally(() => {
                        that.Loading = false;
                    });
                } else {
                    that.Loading = false;
                }
            })
        },
        getFamilyInfor() {
            this.familyInfo = this.$parent.familyInfo;
        },
        getTab12Infor() {
            var that = this;
            postAction(that.url.tab12Infor, {
                ss12001Id: this.$parent.familyInfo.ss12001Id,
                oldSs12001Id: this.$parent.familyInfo.oldSs12001Id
            }).then((res) => {
                if (res.data.errcode == 0) {
                    that.formValidate = res.data.data.ss12001;
                    //验证是否有新增人员，含保障非保障赡抚抚养义务人及家属
                    that.validate18Age = res.data.data.validate18Age;
                    that.validateMessage = res.data.data.validateMessage;
                    if (that.validate18Age == true) {
                        //满足条件则 必须进行经济核查、控件不可用
                        that.formValidate.ssca0090 = '1';
                        that.disabled0090 = true;
                    } else {
                        that.disabled0090 = false;
                    }

                    if (that.formValidate.ssca0059) {
                        that.formValidate.ssca0059 = this.DateFormat(that.formValidate.ssca0059, 'YYYY-MM-DD');
                    }else{
                        if("500,501,503".includes(that.formValidate.ssca0016)){
                            that.formValidate.ssca0059 = this.DateFormat(new Date(), 'YYYY-MM-DD');
                        }else{
                            that.formValidate.ssca0059 = null;
                        }
                    }

                    if (that.formValidate.ssca0037) {
                        that.formValidate.ssca0037 = this.DateFormat(that.formValidate.ssca0037, 'YYYY-MM-DD');
                    } else {
                        if("300".includes(that.formValidate.ssca0016)){
                            that.formValidate.ssca0037 = this.DateFormat(new Date(), 'YYYY-MM-DD');
                        }else{
                            that.formValidate.ssca0037 = null;
                        }
                    }
                    if (that.formValidate.ssca0033) {
                        that.formValidate.ssca0033 = this.DateFormat(that.formValidate.ssca0033, 'YYYY-MM-DD');
                    } else {
                        if("200,204".includes(that.formValidate.ssca0016)){
                            that.formValidate.ssca0033 = this.DateFormat(new Date(), 'YYYY-MM-DD');
                        }else{
                            that.formValidate.ssca0033 = null;
                        }
                    }
                    that.information = res.data.data.information;
                    that.memberInformation = res.data.data.memberInformation;
                } else {
                    that.$Message.error(res.data.errmsg);
                }
            }).finally(() => {
                that.Loading = false;
            });
        },
        //获取家庭成员信息
        getMemberList() {
            var that = this;
            postAction(that.url.getMemberList, {azcp0500: this.$parent.familyInfo.ss17001Id}).then((res) => {
                if (res.data.errcode == 0) {
                    that.memberList = res.data.data;
                } else {
                    that.$Message.error(res.data.errmsg);
                }
            }).finally(() => {
                that.Loading = false;
            });
        }
    }
}
